package com.alan.server2.controller;

import cn.hutool.core.date.DateUtil;
import com.alan.server2.server.Test2Server;
import com.alan.server2.server.TestServer;
import com.alan.share.bean.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by Alan on 17-8-22
 */
@Slf4j
@RestController
@RequestMapping("test")
public class Test2Controller {
    @Autowired
    private Test2Server test2Server;
    @Autowired
    private TestServer testServer;

    @RequestMapping("test")
    public String test(String str){
        log.info("str="+str);
        return "hello "+str;
    }

    @RequestMapping("test2")
    public String test2(String str){
        log.info("str="+str);
        return test2Server.test(str);
    }

    @RequestMapping("test3")
    public String test3(String str){
        log.info("str="+str);
        return testServer.test(str);
    }

    @RequestMapping("user")
    public String user(){
        User user = new User();
        user.setName("alan");
        user.setCreateTime(new Date());
        System.out.println("time:"+ DateUtil.formatDateTime(user.getCreateTime()));
        return test2Server.user(user);

    }

}
